using System;
using System.Data;
using System.Collections.Generic;
using System.Data.SqlClient;
using Core;
using log4net;

namespace DataAccess
{
    public class tbUsers_Proxy
    {
        ILog log = LogManager.GetLogger(typeof(DataAccess.tbUsers).Name);
        Popular cur = new tbUsers();
        public bool Insert_tbUsers_Proxy(Popular cn)
        {
            bool kq = true;
            try
            {
                kq = cur.Insert(cn);
            }
            catch (Exception)
            {
                kq = false;
            }
            if (kq)
                log.Info(" form tbUsers insert success");
            else
                log.Info("form tbUsers insert fail");
            return kq;
        }
        public bool Update_tbUsers_Proxy(Popular cn)
        {
            bool kq = true;
            try
            {
                kq = cur.Update(cn);
            }
            catch (Exception) { kq = false; }
            if (kq)
                log.Info(" form tbUsers update success");
            else
                log.Info("form tbUsers update fail");
            return kq;
        }
        public bool Delete_tbUsers_Proxy(object b)
        {
            bool kq = true;
            try
            {
                kq = cur.Delete(b);
            }
            catch (Exception) { kq = false; }
            if (kq)
                log.Info(" form tbUsers delete success");
            else
                log.Info("form tbUsers delete fail");
            return kq;
        }
        public IDataReader GetById_tbUsers_Proxy(object b)
        {
            log.Info(" form tbUsers Search by Id");
            try { return cur.Select_ID(b); }
            catch (Exception) { throw; }
        }

        public tbUsers GetByUserName_tbUsers_Proxy(object b)
        {
            log.Info(" form tbUsers Search by username");
            try
            {
                return new tbUsers().GetByUserName(b);
            }
            catch (Exception) { throw; }
        }
        public tbUsers GetByEmail_tbUsers_Proxy(object b)
        {
            log.Info(" form tbUsers Search by email");
            try
            {
                return new tbUsers().GetByEmail(b);
            }
            catch (Exception) { throw; }
        }

        public tbUsers GetByResetCode_tbUsers_Proxy(object b)
        {
            log.Info(" form tbUsers Search by reset code");
            try
            {
                return new tbUsers().GetByResetCode(b);
            }
            catch (Exception) { throw; }
        }


        public tbUsers GetById_tbUsers_Proxy(object[] b)
        {
            try { return new tbUsers().Select_ID(b); }
            catch (Exception) { throw; }
        }
        public IDataReader GetByName_tbUsers_Proxy(object b)
        {
            log.Info(" form tbUsers Search by Name");
            return cur.Select_Name(b);
        }
        public IDataReader SelectNo_tbUsers_Proxy(object b)
        {
            log.Info(" form tbUsers Search ");
            if (ConvertType.ToInt(b) != 0)
                return cur.Select_ID(b);
            return cur.Select_Name(b);
        }
        public IDataReader SelectAll_tbUsers_Proxy()
        {
            log.Info(" form tbUsers Load data");
            try { return cur.SelectAll(); }
            catch (Exception) { throw; }
        }
        public List<tbUsers> SelectAlltbUsers_Proxy()
        {
            tbUsers kh = new tbUsers();
            return kh.SelectAllToList();
        }
    }
}